From: Keir Fraser Date: Tue, 4 May 2010 10:48:10 +0000 (+0100) Subject: xl: Add basic bash completion for xl command. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12289 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=9136a919b19929ecb242ef327053d55d824397df;p=xen.git xl: Add basic bash completion for xl command. Signed-off-by: Yang Hongyang --- diff --git a/Config.mk b/Config.mk index 2a0030ce4c..7fe691fed4 100644 --- a/Config.mk +++ b/Config.mk @@ -29,6 +29,7 @@ include $(XEN_ROOT)/config/$(XEN_TARGET_ARCH).mk SHAREDIR ?= $(PREFIX)/share DOCDIR ?= $(SHAREDIR)/doc/xen MANDIR ?= $(SHAREDIR)/man +BASH_COMPLETION_DIR ?= /etc/profile.d ifneq ($(EXTRA_PREFIX),) EXTRA_INCLUDES += $(EXTRA_PREFIX)/include diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index f79bc42abe..4ecbc19e60 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -100,6 +100,7 @@ install: all ln -sf libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(LIBDIR)/libxlutil.so $(INSTALL_DATA) libxlutil.a $(DESTDIR)$(LIBDIR) $(INSTALL_DATA) libxl.h $(DESTDIR)$(INCLUDEDIR) + $(INSTALL_DATA) bash-completion $(BASH_COMPLETION_DIR)/xl.sh .PHONY: clean clean: diff --git a/tools/libxl/bash-completion b/tools/libxl/bash-completion new file mode 100644 index 0000000000..4b870e6602 --- /dev/null +++ b/tools/libxl/bash-completion @@ -0,0 +1,21 @@ +#!/bin/bash +# Copy this file to /etc/profile.d/xl.sh + +_xl() +{ + local IFS=$'\n,' + + local cur opts xl + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + xl=xl + + if [[ $COMP_CWORD == 1 ]] ; then + opts=`${xl} help 2>/dev/null | sed 'n;d' | sed '1,2d' | awk '{print $1}' | sed 's/$/ ,/g'` && COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi + + return 0 +} + +complete -F _xl -o nospace -o default xl